#include <stdlib.h>
#include <stdio.h>
#include <sys/wait.h>
#include <unistd.h>
#include "usecpu.h"

// Spawns argv[1] processes that each uses all available cpu,
// then waits for them all to exit.
int main(int argc, char *argv[]) {
	if (argc != 2) {
		printf("Usage: %s NUM\n", argv[0]);
		printf("Where NUM is the number of processes\n");
		return 1;
	}
	
	int procs = atoi(argv[1]);
	int i;
	
	for (i = 0; i < procs; i++)
		if (fork() == 0) usecpu();
	
	for (i = 0; i < procs; i++)
		wait(NULL);

	return 0;
}
